import CanvasAbstract from './CanvasAbstract'
import BulletModel from '../model/bullet'
import tank from './tank'
import bullet from '../model/bullet'
import play from './play'
import audio from '../service/audio'
class Bullet extends CanvasAbstract implements ICanvas {
  intervalId = 0
  num(): number {
    return 0
  }
  stop() {
    clearInterval(this.intervalId)
  }
  model(): BulletConstruct {
    return BulletModel
  }
  rander(): void {
    this.intervalId = setInterval(() => {
      this.createBullet()
      this.renderModel()
    }, 20)
    // super.createModels()
    // super.renderModel()
  }
  createBullet() {
    tank.models.forEach(tank => {
      const isExists = this.models.some(m => m.tank == tank)

      if (!isExists) {
        this.models.push(new bullet(tank))
        // audio.fire()
      }
    })
  }
  addPlearBullet() {
    this.models.push(new bullet(play.models[0]))
    audio.fire()
  }
}

export default new Bullet('bullet')
